<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--导入easyui样式 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/icon.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<title>查看订单</title>
</head>
<script type="text/javascript">
$(function () {
	$("#dg").datagrid({
		url:'selectOrders',
		columns:[[   
		          {field:'ck',checkbox:true},		           
		          {field:'oid',title:'订单号',width:90},
		          {field:'orderstatus',title:'订单状态',width:90},
		          {field:'weight',title:'重量',width:90},
		          {field:'volume',title:'体积',width:90},
		          {field:'fhdate',title:'发送日期',width:90},
		          {field:'place',title:'配送地',width:90},
		          {field:'plate',title:'车牌号',width:90},
		          {field:'receipt',title:'收寄地',width:90},
		          {field:'goodsname',title:'物品名',width:90},
		          {field:'goodstype',title:'物品类别',width:90},
		          {field:'remarks',title:'备注',width:90},		             		          		        	         		          		          		          		       	        
		      ]],
		      rownumbers:true,
		      pagination:true,
		      pagePosition:'bottom',
		      pageSize:3,
		      pageList:[5,10,20],
		      toolbar: [{
		  		iconCls: 'icon-edit',
		  		text:'车辆调配',
		  		handler: function(){
		  			var  stus= $('#dg').datagrid('getSelections');
		  			if(stus.length!=1){
		  				$.messager.alert('信息','请选择一条数据','info');	
	  					$('#dg').datagrid('load');
		  			}else{
		  				$("#updateOrders").dialog("open").dialog('setTitle', '车辆调配');
		  				var ss=stus[0].orderstatus;
		  				if(ss=="运输中"){
		  					$.messager.alert('信息','该订单已分配车辆,不能重复分配车辆','info');	
		  					$("#updateOrders").dialog("close");
		  					$('#dg').datagrid('load');
		  				}else{
		  				$('#ss1').combobox({    
			  			  	url:'selectPlate',    
			  			  	valueField:'id',    
			  			  	textField:'text'   
			  			  	});
		  				$('#cc1').combobox({    
			  			  	url:'selectOrderstatus',    
			  			  	valueField:'id',    
			  			  	textField:'text'   
			  			  	});
		  				$('#ck').val(stus[0].oid);
		  				$('#ss1').combobox('setValue', stus[0].plate);
		  				$('#cc1').combobox('setValue', stus[0].orderstatus);
		  				$('#cancl1').linkbutton({
		  					onClick:function(){
		  						$("#update").form('clear');  						
	  							$("#updateCarposition").dialog("close");
	  							 $('#dg').datagrid('load');
		  					}
		  				})
		  				$("#save2").linkbutton({
		  					onClick:function(){
		  						var oid=$("#ck").val();	 						
		  						var Plate =$("#ss1").combobox('getText');		  				
			  					 var orderstatus =$("#cc1").combobox('getText');			  					
			  					$.ajax({
			  						url:'updateOrderstatus',
			  						type:'post',
			  					data:
			  					{'Plate':Plate,'Orderstatus':orderstatus,'oid':oid},
			  					dataType:'text',
			  					success:function(yy){
			  						if(yy==1){
			  							$.messager.alert('信息','修改成功','info');
			  							$("#update").form('clear');  						
			  							$("#updateOrders").dialog("close");
			  							 $('#dg').datagrid('load');
			  						}
			  					}
			  					})
		  					}
		  				})
		  			}}
		  		}		  	
		  	}]

	})
	
})
</script>
<body>
<table id="dg"></table>
<!--修改彈出窗口 -->
<div id="updateOrders" class="easyui-dialog"  closed="true" buttons="#dlg2-buttons" style="width: 300px;height: 300px" >
<br>
<form id="update">
<div style="margin-top:10px;text-align: center;">
<input id="ck"name="oid" type="text"style="display:none"><br><br>
车牌号<input id="ss1" name="plate" value=""editable="false"><br><br>
订单状态<input id="cc1"name="orderstatus"  value=""editable="false"><br><br>
</div>
</form>
<div id="dlg1-buttons" style="margin-top:10px;text-align: center;" >
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button id="save2"  class="easyui-linkbutton"  iconcls="icon-save">确定</button>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id="cancl1" class="easyui-linkbutton" onclick="javascript:$('#updateOrders').dialog('close')" iconcls="icon-cancel">取消</a>
</div>
</div>
</body>
</html>